package com.restaurant.springboot.entity;

import javax.persistence.*;
import java.util.Objects;

@Entity
@Table(name = "shopping_cart", schema = "restaurant", catalog = "")
@IdClass(ShoppingCartEntityPK.class)
public class ShoppingCartEntity {

    private int userId;
    private int dishesId;
    private int number;

    @Id
    @Column(name = "user_id")
    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    @Id
    @Column(name = "dishes_id")
    public int getDishesId() {
        return dishesId;
    }

    public void setDishesId(int dishesId) {
        this.dishesId = dishesId;
    }

    @Basic
    @Column(name = "number")
    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ShoppingCartEntity that = (ShoppingCartEntity) o;
        return userId == that.userId &&
                dishesId == that.dishesId &&
                number == that.number;
    }

    @Override
    public int hashCode() {
        return Objects.hash(userId, dishesId, number);
    }
}
